const log = require('./common');

function deepClone(obj){
    if(obj === null || typeof obj !== 'object') return obj;

    const result = Array.isArray(obj) ? [] : {};

    for(let key in obj){
        if(obj.hasOwnProperty(key)){
            result[key] = deepClone(obj[key])
        }
    }

    return result;
}

let clone_arr = deepClone([1,2,3]);
let clone_obj = deepClone({name:'zjh',age:25});
log(clone_arr,clone_obj);